<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="./js/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="app">
        <h2>{{title}}</h2>
        <input type="text" :value="title" @change="changetitle">
        <div @click="parentclick">
            我们是最棒的哦-wh2116
            <p @click.stop="funcOne">Vue is so easy????</p>
            <p @click.prevent="funcTwo">这几天千万要把Vue API 速记 </p>
            <p>wh2116 - daydayup </p>
        </div>
        <input type="text" @keydown.13.32.40.39.38.37="getKeycode($event)">
        <hr>
        <h2>{{num2 |currency(num)}}</h2>
        <h2>{{num2 |currency(num)}}</h2>
        <input type="text" v-model="num" name="" id="">

    </div>
</body>
<script>
    const vm = new Vue({
        el: "#app",
        data: {
            title: "双向绑定title",
            num: "1008",
            num2: "1"
        },
        methods: {
            parentclick(e) {
                console.log(e);
                console.log("父级点击!")
            },
            funcOne(e) {
                console.log(e);
                console.log("子级1点击!")
            },
            funcTwo(e) {
                console.log(e);
                console.log("子级2点击!")
            },
            changetitle(e) {
                this.title = e.target.value
            },
            getKeycode(e) {
                console.log(e.keyCode)
            }
        }
    })
    Vue.filter('currency', (value, type = "$") => {

        if (!value) return value;
        value = value.toString().split("")
        // value.push(type)
        console.log(type)
        this.num2 = value
        console.log(value)
        return this.num2
    })
</script>

</html>